<?php
class Insumos_model extends CI_Model {
    public function __construct() {
        $this->load->database();
    }
    
    public function get_insumos() {
        $query = $this->db->query("SELECT *
                                    FROM
                                        insumos
                                    ORDER BY
                                        insumo");
        return $query->result_array();
    }
    
    public function get_insumo($idinsumo) {
        $query = $this->db->query("SELECT *
                                    FROM
                                        insumos
                                    WHERE
                                        idinsumo = $idinsumo");
        return $query->row_array();
    }
    
    public function update($datos, $id) {
        $idinsumo = array(
            'idinsumo' => $id
        );
        
        $this->db->update('insumos', $datos, $idinsumo);
    }
    
    public function set_insumo($datos) {
        $this->db->insert('insumos', $datos);
    }
}
?>
